from django import forms
from apps.forms import FormMixin
from apps.news.models import News
from apps.course.models import Course


class EditCategory(forms.Form, FormMixin):
    pk = forms.IntegerField(error_messages={"required": "必须输入id"})
    name = forms.CharField(max_length=100)


class AddNews(forms.ModelForm, FormMixin):
    category = forms.IntegerField()

    class Meta:
        model = News
        exclude = ['category', 'author', 'pub_time']


class EditNews(forms.ModelForm, FormMixin):
    category = forms.IntegerField()
    pk = forms.IntegerField()

    class Meta:
        model = News
        exclude = ['category', 'author', 'pub_time']


class PubCourseForm(forms.ModelForm,FormMixin):
    category_id = forms.IntegerField()
    teacher_id = forms.IntegerField()

    class Meta:
        model = Course
        exclude = ("category",'teacher')

